﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gebra.Test
{
    [TestClass]
    public class MultiplyTest
    {
        [TestMethod]
        public void ConstructWithNumbers()
        {
            var add = new Multiply(new Number(23), new Number(42));

            var result = add.Evaluate() as Number;

            Assert.IsNotNull(result);
            Assert.AreEqual(966, (double)result);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructWithNullLeft()
        {
            new Multiply(a_left: null, a_right: (Number)42);
        }

        [TestMethod]
        public void EvaluateMultiplication()
        {
            new Multiply((Number) 23, (Number) 42);
        }

        [TestMethod]
        public void EvaluateThreeNumberMultiplication()
        {
            var multiply = new Number(23).Multiply(36).Multiply(42);

            var result = multiply.Evaluate() as Number;

            Assert.AreEqual(34776, (double)result);
        }

        [TestMethod]
        public void EvaluateCombinationOfAdditionAndMultiplication()
        {
            var multiply = ((Number)14).Multiply(2).Add(1);

            var result = multiply.Evaluate() as Number;

            Assert.AreEqual(29, (double)result);
        }
    }
}
